import React, { useState, useEffect } from 'react'; import { ShoppingCart, X, Plus, Minus, MapPin, Phone, Clock, ArrowRight, CheckCircle2 } from 'lucide-react'; // --- 數據定義 (Data Models) --- // 基於資料驅動視圖的邏輯,將商品資訊獨立出來,便於未來串接資料庫 const PRODUCTS = [ { id: 1, name: '雲朵特級床墊', description: '多層次獨立筒與透氣記憶棉的完美結合,給予脊椎最適切的支撐。', price: 15800, image: 'https://images.unsplash.com/photo-1554995207-c18c203602cb?q=80&w=800&auto=format&fit=crop' }, { id: 2, name: '呼吸記憶枕', description: '慢回彈高密度材質,符合人體工學,釋放頸部壓力。', price: 2500, image: 'https://images.unsplash.com/photo-1584100936595-c0654b55a2e6?q=80&w=800&auto=format&fit=crop' }, { id: 3, name: '輕柔純棉被套組', description: '100% 雙層水洗棉,如同親膚內衣般的極致柔軟體驗。', price: 3200, image: 'https://images.unsplash.com/photo-1522771731535-64582f34791a?q=80&w=800&auto=format&fit=crop' } ]; export default function App() { // --- 狀態管理 (State Management) --- const [cart, setCart] = useState([]); const [isCartOpen, setIsCartOpen] = useState(false); const [toastMessage, setToastMessage] = useState(null); // --- 業務邏輯 (Business Logic) --- const addToCart = (product) => { setCart(prevCart => { const existingItem = prevCart.find(item => item.id === product.id); if (existingItem) { return prevCart.map(item => item.id === product.id ? { ...item, quantity: item.quantity + 1 } : item ); } return [...prevCart, { ...product, quantity: 1 }]; }); setIsCartOpen(true); }; const updateQuantity = (id, delta) => { setCart(prevCart => { return prevCart.map(item => { if (item.id === id) { const newQuantity = item.quantity + delta; return newQuantity > 0 ? { ...item, quantity: newQuantity } : null; } return item; }).filter(Boolean); // 過濾掉 null 的項目 (即數量被扣到 0 的商品) }); }; const handleCheckout = () => { if (cart.length === 0) return; // 模擬送出訂單 setIsCartOpen(false); setCart([]); showToast("訂單已成功送出!感謝您的購買。"); }; const showToast = (msg) => { setToastMessage(msg); setTimeout(() => setToastMessage(null), 3000); }; // 衍生狀態 (Derived State) const cartTotal = cart.reduce((total, item) => total + (item.price * item.quantity), 0); const cartItemCount = cart.reduce((count, item) => count + item.quantity, 0); return ( // 使用指定的色彩計畫,並設定全域字體與背景紋理
{/* 系統提示訊息 (Toast) */} {toastMessage && (
{toastMessage}
)} {/* --- 導覽列 (Navigation) --- */} {/* --- 英雄區塊 (Hero Section) --- */}
{/* 背景大字裝飾 (Oversized background typography) */}
BREATHE
NEW LIFESTYLE

讓每一晚的睡眠,
都充滿呼吸感

以現代日系簡約為核心,我們重新定義了寢具的有機感與舒適度。為理性的你,提供最純粹的支撐。

{/* 浮動佈局的圖片容器 (Floating layout with hyper-rounded corners) */}
SYH bad minimalist bedroom
★★★★★

"支撐力符合物理力學,完美的平衡。"

{/* --- 產品區塊 (Products Section) --- */}

純粹之選

去除多餘裝飾,只保留睡眠最需要的機能與舒適。

{PRODUCTS.map(product => (
{product.name}

{product.name}

{product.description}

NT$ {product.price.toLocaleString()}

))}
{/* --- 店家資訊區塊 (Store Information) --- */}

門市體驗空間

我們深知數據無法取代體感。歡迎來到我們位於台北的實體據點,親自感受每一寸材質的回饋力道與呼吸感。

SYH bad 台北旗艦店

106 台北市大安區羅斯福路四段1號
(近台大公館商圈)

營業時間

週一至週日 11:00 - 21:00

客服專線

02-2366-XXXX

{/* 抽象的地圖視覺表示 (避免真實地圖 iframe 帶來的效能與風格破壞) */}
大安區實體據點
{/* --- 頁尾 (Footer) --- */} {/* --- 購物車側邊欄 (Shopping Cart Drawer) --- */} {/* 背景遮罩 */} {isCartOpen && (
setIsCartOpen(false)} /> )} {/* 側邊欄面板 */}
{/* 購物車頭部 */}

購物車

{/* 購物車商品列表 */}
{cart.length === 0 ? (

您的購物車目前是空的

) : ( cart.map(item => (
{item.name}

{item.name}

NT$ {item.price.toLocaleString()}

{/* 數量控制按鈕 (Pill-shaped) */}
{item.quantity}
)) )}
{/* 結帳區塊 */} {cart.length > 0 && (
總計 NT$ {cartTotal.toLocaleString()}
)}
); }